package com.zxw.设计模式.创建型.工厂模式.a生产客户端测试;

import com.zxw.设计模式.创建型.工厂模式.产品.抽象产品.AbstractFreeszer;
import com.zxw.设计模式.创建型.工厂模式.产品.抽象产品.AbstractTV;
import com.zxw.设计模式.创建型.工厂模式.工厂.具体工厂.HairFactory;
import com.zxw.设计模式.创建型.工厂模式.工厂.具体工厂.HiasenseFactory;
import com.zxw.设计模式.创建型.工厂模式.工厂.抽象工厂.ApplicationFactory;

/**
 * @projectName: util-cloud
 * @package: com.zxw.设计模式.创建型.工厂模式.生产测试
 * @className: TestFactory
 * @author: zhangxuewei
 * @description: TODO
 * @date: 2023/5/8 14:14
 * @version: 1.0
 */
public class FactoryClient {

    private AbstractTV tv;

    private AbstractFreeszer freeszer;

    public AbstractTV getTv() {
        return tv;
    }

    public AbstractFreeszer getFreeszer() {
        return freeszer;
    }

    public FactoryClient(ApplicationFactory applicationFactory) {
        this.tv = applicationFactory.createTV();
        this.freeszer = applicationFactory.createFreezer();
    }

    public static void main(String[] args) {
        FactoryClient hairClient = new FactoryClient(new HairFactory());
        AbstractTV haTv = hairClient.getTv();
        System.out.println(haTv.printName());
        AbstractFreeszer haFreeszer = hairClient.getFreeszer();
        System.out.println(haFreeszer.printName());

        FactoryClient hiasenseClient = new FactoryClient(new HiasenseFactory());
        AbstractTV hiTv = hiasenseClient.getTv();
        System.out.println(hiTv.printName());
        AbstractFreeszer hiFreeszer = hiasenseClient.getFreeszer();
        System.out.println(hiFreeszer.printName());
    }
}
